package com.itheima.service.impl;

import com.itheima.mapper.EmpMapper;
import com.itheima.mapper.StudentMapper;
import com.itheima.pojo.*;
import com.itheima.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


@Service
public class ReportServiceImpl implements ReportService {

@Autowired
    EmpMapper empMapper;
@Autowired
    StudentMapper studentMapper;
//部门人数统计，获取JobOption类的返回值
    @Override
    public JobOption getEmpJobData() {
      List<JobData> jobData= empMapper.getempjobdata();
      List<String> joblist=new ArrayList<>();
      List<Integer> datalist=new ArrayList<>();
      for (JobData a:jobData){
          joblist.add(a.getPos());
          datalist.add(a.getNum());
        }
      JobOption jo=new JobOption(joblist,datalist);
        return jo;
    }

    @Override
    public List<GenderData> getgenderdata() {
        return empMapper.getgender();
    }

    @Override
    public List<EduBackgData> getEduBackg() {
      List<EduBackgData> eduBackgDataList=studentMapper.getEduBackgData();
        return eduBackgDataList;
    }

    @Override
    public ClazzDataQD getClazzNunData() {
        List<ClazzDataHD>clazzDataHDList=studentMapper.getClazzNunData();
        List<String> clazzList=new ArrayList<>();
        List<Integer> number=new ArrayList<>();
        for(ClazzDataHD a:clazzDataHDList){
            clazzList.add(a.getClazz());
            number.add(a.getNum());
        }
        ClazzDataQD clazzDataQD=new ClazzDataQD(clazzList,number);
        return clazzDataQD;
    }
}
